-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parse benchmark #104
Add parse benchmark #104
Conversation
1ba69ad
to
31334b5
Compare
31334b5
to
55a145b
Compare
Rakefile
Outdated
benchmark_tasks << "benchmark:#{name}" | ||
|
||
case name | ||
when /\Aparse/, "shift" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when /\Aparse/, "shift" | |
when /\Aparse/ |
benchmark/parse.yaml
Outdated
'dom' : REXML::Document.new(xml).elements.each("root/child") {|_|} | ||
'sax' : REXML::Parsers::SAX2Parser.new(xml).parse | ||
'pull' : | | ||
p = REXML::Parsers::PullParser.new(xml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using parser
for variable name because we have p
method?
p = REXML::Parsers::PullParser.new(xml) | |
parser = REXML::Parsers::PullParser.new(xml) |
benchmark/parse.yaml
Outdated
'pull' : | | ||
p = REXML::Parsers::PullParser.new(xml) | ||
while p.has_next? | ||
res = p.pull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that we don't need to assign the return value:
res = p.pull | |
p.pull |
benchmark/parse.yaml
Outdated
n_elements = Integer(ENV.fetch("N_ELEMENTS", "10000"), 10) | ||
n_attributes = Integer(ENV.fetch("N_ATTRIBUTES", "10"), 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With these configurations, we take 10+ minutes for one rake benchmark
: https://github.com/ruby/rexml/actions/runs/7431570516/job/20222471649?pr=104
Can we reduce benchmark time? Or do we need these numbers for meaningful benchmark?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set this value because I need to execute XML with a large number of elements, but the execution time is too long, so I will reduce the number of elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ruby/rexml/actions/runs/7434389228/job/20228488163?pr=104
Reduced to 1/4. (2 minutes 38 seconds)
55a145b
to
e4af9f3
Compare
Thanks! |
I want to improve the parsing process and would like to add a parsing benchmark.
The benchmark process just parses the XML from beginning to end.
Since performance differs depending on whether YJIT is ON or OFF, both are measured.